﻿using ArticleandSiteData;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace Dong
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class AddImagePage : Page
    {
        public AddImagePage()
        {
            this.InitializeComponent();
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            DataVMClass M = new DataVMClass();
            await M.Getcategorylist(listimg);
            base.OnNavigatedTo(e);
        }

        private async void add_Click(object sender, RoutedEventArgs e)
        {
            string url = "https://api.bmob.cn/1/classes/imageinfo";
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("imageurl", imageurl.Text);
            dic.Add("imagetext", imagetext.Text);
            dic.Add("siteurl", siteurl.Text);
            dic.Add("imagecategory", listimg.SelectedValue.ToString());
           bool r=   await RequestHelper.addsimpleobject(url, dic);
            if(!r)
            {
               
            }
            else
            {
                imagetext.Text = string.Empty;
                siteurl.Text = string.Empty;
                imageurl.Text = string.Empty;
            }
        }
    }
}
